﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<BizCollegeWebApp.Models.Course>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Index
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<h2>List of courses</h2>

<form action="" method="post">
    <input class="searchbox" id="SearchTerm" name="SearchTerm" type="text" value="<%: ViewBag.SearchTerm.ToString() %>"/> 
    <input type="submit" value="Search Courses" />
    <%: Html.ActionLink("Clear", "Index") %>
</form>

<br />

<table>
    <tr>
        <th>
            CourseName
        </th>
        <th>
            CourseDesciption
        </th>
        <th>
            CourseState
        </th>
        <th></th>
    </tr>

<% foreach (var item in Model) { %>
    <tr>
        <td>
            <%: Html.DisplayFor(modelItem => item.CourseName) %>
        </td>
        <td>
            <%: Html.DisplayFor(modelItem => item.CourseDesciption) %>
        </td>
        <td>
            <%: Html.DisplayFor(modelItem => item.CourseState.StateName) %>
        </td>
        <td>
            <%: Html.ActionLink("Edit", "EditCourse", new { id = item.CourseID })%> |
            <%: Html.ActionLink("Take Survey", "TakeSurvey", "Survey", new { courseId = item.CourseID }, null)%> |
              <%: Html.ActionLink("Survey Results", "Results", "Survey", new { courseId =item.CourseID }, null) %> | 
            <% if (Current.User.IsEnrolled(item.CourseID)) 
               {%>
            <%: Html.ActionLink("Browse the course", "ViewCourse", new { id = item.CourseID })%> 
            <%}
               else
               { %>
            <%--  <%: Html.ActionLink("Take a test to view the course", "TakeTest", new { id = Model.CourseID })%> --%>
              <%--  <%: Html.ActionLink("Register to the course", "PreReqTest", "Test", new { courseId = item.CourseID }, null)%> --%>
          
               <%: Html.ActionLink("Register to the course", "Enroll", new { id = item.CourseID })%> 
           <%} %>
            |
            <%: Html.ActionLink("Delete", "Delete", new { id=item.CourseID }) %>
        </td>
    </tr>
<% } %>

</table>
<p>
    <%: Html.ActionLink("Add New Course", "Create") %>
</p>

</asp:Content>
